package tld.test.menu
{
	import flash.display.Sprite;
	import flash.events.Event;
	
	import tld.test.menu.challenges.AshesToAshes;
	import tld.test.menu.challenges.ChallengeEvent;
	
	public class AshesTest extends Sprite
	{
		public function AshesTest()
		{
			super();
			if (super.stage) this.init();
			else super.addEventListener(
				Event.ADDED_TO_STAGE, this.init);
		}
		
		private function init(event:Event = null):void
		{
			super.removeEventListener(
				Event.ADDED_TO_STAGE, this.init);
			var ashes:AshesToAshes = new AshesToAshes();
			super.addChild(ashes);
			ashes.reset(["circle", "triangle", "square"], 
				["circle", "triangle", "square"]);
			ashes.addEventListener(
				ChallengeEvent.LOOSE, this.looseHandler);
			ashes.addEventListener(
				ChallengeEvent.WIN, this.winHandler);
		}
		
		private function looseHandler(event:ChallengeEvent):void
		{
			trace("Try harder!");
		}
		
		private function winHandler(event:ChallengeEvent):void
		{
			trace("Genuis!");
		}
	}
}